package View;

import Control.ctrAnimal;
import java.awt.Image;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;

public final class limAnimal extends javax.swing.JPanel {
    private ctrAnimal control;
    private String codAnterior = "";
    private ImageIcon imgRedimensionada;


    public limAnimal(ctrAnimal objControl) {
        this.control = objControl;
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        combo_especie = new javax.swing.JComboBox();
        combo_raca = new javax.swing.JComboBox();
        combo_porte = new javax.swing.JComboBox();
        label_dt_nascimento = new javax.swing.JLabel();
        combo_data_dia = new javax.swing.JComboBox();
        combo_data_mes = new javax.swing.JComboBox();
        combo_data_ano = new javax.swing.JComboBox();
        label_observacao = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea_observacoes = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        field_nome = new javax.swing.JTextField();
        field_apelido = new javax.swing.JTextField();
        label_apelido = new javax.swing.JLabel();
        label_nome = new javax.swing.JLabel();
        label_especie = new javax.swing.JLabel();
        label_raca = new javax.swing.JLabel();
        label_porte = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        label_foto = new javax.swing.JLabel();
        field_foto = new javax.swing.JTextField();
        panel_acrescenta = new javax.swing.JPanel();
        botao_novo = new javax.swing.JButton();
        botao_acrescenta = new javax.swing.JButton();
        label_acrescenta = new javax.swing.JLabel();
        botao_foto = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        field_codigo = new java.awt.TextField();
        botao_anterior = new javax.swing.JButton();
        botao_proximo = new javax.swing.JButton();
        panel_fotografia = new javax.swing.JPanel();
        label_fotografia = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(849, 303));
        setPreferredSize(new java.awt.Dimension(849, 303));

        combo_especie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_especieActionPerformed(evt);
            }
        });

        combo_raca.setInheritsPopupMenu(true);

        label_dt_nascimento.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_dt_nascimento.setText("Nascimento:");

        combo_data_dia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Dia", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        combo_data_mes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mês", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        combo_data_ano.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ano", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996" }));

        label_observacao.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_observacao.setText("Observações:");

        textArea_observacoes.setColumns(20);
        textArea_observacoes.setFont(textArea_observacoes.getFont());
        textArea_observacoes.setRows(5);
        textArea_observacoes.setToolTipText("Anotações importantes sobre o animal");
        jScrollPane1.setViewportView(textArea_observacoes);

        label_apelido.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_apelido.setText("Apelido:");

        label_nome.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_nome.setText("Nome:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(label_apelido)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(field_apelido, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(label_nome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(field_nome, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_nome)
                    .addComponent(field_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_apelido)
                    .addComponent(field_apelido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        label_especie.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_especie.setText("Espécie");

        label_raca.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_raca.setText("Raça");

        label_porte.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_porte.setText("Porte");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(label_dt_nascimento)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_dia, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_mes, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_ano, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(combo_especie, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(label_especie))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(combo_raca, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(label_raca))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(label_porte)
                                    .addComponent(combo_porte, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(label_observacao))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_especie)
                    .addComponent(label_porte)
                    .addComponent(label_raca))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(combo_especie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_raca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_porte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(combo_data_dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_data_mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_data_ano, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_dt_nascimento))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(label_observacao)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        label_foto.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_foto.setText("Foto:");

        field_foto.setMaximumSize(new java.awt.Dimension(10, 20));
        field_foto.setMinimumSize(new java.awt.Dimension(10, 20));
        field_foto.setPreferredSize(new java.awt.Dimension(10, 20));

        panel_acrescenta.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));

        botao_novo.setFont(new java.awt.Font("Tahoma", 1, 14));
        botao_novo.setText("Novo");
        botao_novo.setToolTipText("Novo registro");
        botao_novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_novoActionPerformed(evt);
            }
        });

        botao_acrescenta.setFont(new java.awt.Font("Tahoma", 1, 14));
        botao_acrescenta.setText("Acrescentar");
        botao_acrescenta.setToolTipText("Novo registro");
        botao_acrescenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_acrescentaActionPerformed(evt);
            }
        });

        label_acrescenta.setFont(new java.awt.Font("Tahoma", 1, 12));
        label_acrescenta.setText("Acrescentar animal");

        javax.swing.GroupLayout panel_acrescentaLayout = new javax.swing.GroupLayout(panel_acrescenta);
        panel_acrescenta.setLayout(panel_acrescentaLayout);
        panel_acrescentaLayout.setHorizontalGroup(
            panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_acrescentaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botao_novo, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                    .addComponent(botao_acrescenta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(label_acrescenta))
                .addContainerGap())
        );
        panel_acrescentaLayout.setVerticalGroup(
            panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_acrescentaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_acrescenta)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_novo, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_acrescenta, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addContainerGap())
        );

        botao_foto.setFont(new java.awt.Font("Tahoma", 1, 11));
        botao_foto.setText("...");
        botao_foto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_fotoActionPerformed(evt);
            }
        });

        field_codigo.setCursor(new java.awt.Cursor(java.awt.Cursor.E_RESIZE_CURSOR));
        field_codigo.setEditable(false);
        field_codigo.setForeground(new java.awt.Color(255, 51, 102));

        botao_anterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/registro_anterior.gif"))); // NOI18N
        botao_anterior.setToolTipText("Cadastro anterior");
        botao_anterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_anteriorActionPerformed(evt);
            }
        });

        botao_proximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/proximo_registro.gif"))); // NOI18N
        botao_proximo.setToolTipText("Próximo cadastro");
        botao_proximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_proximoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addComponent(botao_anterior)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(field_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_proximo)
                .addGap(63, 63, 63))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(botao_anterior, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(field_codigo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(botao_proximo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        panel_fotografia.setBackground(new java.awt.Color(255, 51, 102));

        javax.swing.GroupLayout panel_fotografiaLayout = new javax.swing.GroupLayout(panel_fotografia);
        panel_fotografia.setLayout(panel_fotografiaLayout);
        panel_fotografiaLayout.setHorizontalGroup(
            panel_fotografiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_fotografiaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                .addContainerGap())
        );
        panel_fotografiaLayout.setVerticalGroup(
            panel_fotografiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_fotografiaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(label_foto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(panel_acrescenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(field_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(botao_foto)
                        .addGap(27, 27, 27)
                        .addComponent(panel_fotografia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(field_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botao_foto)
                            .addComponent(label_foto))
                        .addGap(53, 53, 53)
                        .addComponent(panel_acrescenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(panel_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(72, 72, 72))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(30, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    public limAnimal() {
        JFrame frame = new JFrame();
        JPanel panel = this.geraInterface();
        frame.add(panel);
        frame.setVisible(true);      
    }


    public JPanel geraInterface() {

        JPanel panel = new JPanel();
        
       jPanel1 = new javax.swing.JPanel();
        combo_especie = new javax.swing.JComboBox();
        combo_raca = new javax.swing.JComboBox();
        combo_porte = new javax.swing.JComboBox();
        label_dt_nascimento = new javax.swing.JLabel();
        combo_data_dia = new javax.swing.JComboBox();
        combo_data_mes = new javax.swing.JComboBox();
        combo_data_ano = new javax.swing.JComboBox();
        label_observacao = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea_observacoes = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        field_nome = new javax.swing.JTextField();
        field_apelido = new javax.swing.JTextField();
        label_apelido = new javax.swing.JLabel();
        label_nome = new javax.swing.JLabel();
        label_especie = new javax.swing.JLabel();
        label_raca = new javax.swing.JLabel();
        label_porte = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        label_foto = new javax.swing.JLabel();
        field_foto = new javax.swing.JTextField();
        panel_acrescenta = new javax.swing.JPanel();
        botao_novo = new javax.swing.JButton();
        botao_acrescenta = new javax.swing.JButton();
        label_acrescenta = new javax.swing.JLabel();
        botao_foto = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        field_codigo = new java.awt.TextField();
        botao_anterior = new javax.swing.JButton();
        botao_proximo = new javax.swing.JButton();
        panel_fotografia = new javax.swing.JPanel();
        label_fotografia = new javax.swing.JLabel();

        panel.setMaximumSize(new java.awt.Dimension(849, 303));
        panel.setPreferredSize(new java.awt.Dimension(849, 303));

        combo_especie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_especieActionPerformed(evt);
            }
        });

        combo_raca.setInheritsPopupMenu(true);

        label_dt_nascimento.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_dt_nascimento.setText("Nascimento:");

        combo_data_dia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Dia", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        combo_data_mes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mês", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        combo_data_ano.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ano", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996" }));

        label_observacao.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_observacao.setText("Observações:");

        textArea_observacoes.setColumns(20);
        textArea_observacoes.setFont(textArea_observacoes.getFont());
        textArea_observacoes.setRows(5);
        textArea_observacoes.setToolTipText("Anotações importantes sobre o animal");
        jScrollPane1.setViewportView(textArea_observacoes);

        label_apelido.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_apelido.setText("Apelido:");

        label_nome.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_nome.setText("Nome:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(label_apelido)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(field_apelido, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(label_nome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(field_nome, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_nome)
                    .addComponent(field_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_apelido)
                    .addComponent(field_apelido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        label_especie.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_especie.setText("Espécie");

        label_raca.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_raca.setText("Raça");

        label_porte.setFont(new java.awt.Font("Tahoma", 0, 12));
        label_porte.setText("Porte");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(label_dt_nascimento)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_dia, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_mes, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(combo_data_ano, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(combo_especie, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(label_especie))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(combo_raca, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(label_raca))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(label_porte)
                                    .addComponent(combo_porte, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(label_observacao))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_especie)
                    .addComponent(label_porte)
                    .addComponent(label_raca))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(combo_especie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_raca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_porte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(combo_data_dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_data_mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(combo_data_ano, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_dt_nascimento))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(label_observacao)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        label_foto.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_foto.setText("Foto:");

        field_foto.setMaximumSize(new java.awt.Dimension(10, 20));
        field_foto.setMinimumSize(new java.awt.Dimension(10, 20));
        field_foto.setPreferredSize(new java.awt.Dimension(10, 20));

        panel_acrescenta.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));

        botao_novo.setFont(new java.awt.Font("Tahoma", 1, 14));
        botao_novo.setText("Novo");
        botao_novo.setToolTipText("Novo registro");
        botao_novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_novoActionPerformed(evt);
            }
        });

        botao_acrescenta.setFont(new java.awt.Font("Tahoma", 1, 14));
        botao_acrescenta.setText("Acrescentar");
        botao_acrescenta.setToolTipText("Novo registro");
        botao_acrescenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_acrescentaActionPerformed(evt);
            }
        });

        label_acrescenta.setFont(new java.awt.Font("Tahoma", 1, 12));
        label_acrescenta.setText("Acrescentar animal");

        javax.swing.GroupLayout panel_acrescentaLayout = new javax.swing.GroupLayout(panel_acrescenta);
        panel_acrescenta.setLayout(panel_acrescentaLayout);
        panel_acrescentaLayout.setHorizontalGroup(
            panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_acrescentaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botao_novo, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                    .addComponent(botao_acrescenta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(label_acrescenta))
                .addContainerGap())
        );
        panel_acrescentaLayout.setVerticalGroup(
            panel_acrescentaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_acrescentaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_acrescenta)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_novo, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_acrescenta, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addContainerGap())
        );

        botao_foto.setFont(new java.awt.Font("Tahoma", 1, 11));
        botao_foto.setText("...");
        botao_foto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_fotoActionPerformed(evt);
            }
        });

        field_codigo.setCursor(new java.awt.Cursor(java.awt.Cursor.E_RESIZE_CURSOR));
        field_codigo.setEditable(false);
        field_codigo.setForeground(new java.awt.Color(255, 51, 102));

        botao_anterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/registro_anterior.gif"))); // NOI18N
        botao_anterior.setToolTipText("Cadastro anterior");
        botao_anterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_anteriorActionPerformed(evt);
            }
        });

        botao_proximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/proximo_registro.gif"))); // NOI18N
        botao_proximo.setToolTipText("Próximo cadastro");
        botao_proximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_proximoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addComponent(botao_anterior)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(field_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botao_proximo)
                .addGap(63, 63, 63))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(botao_anterior, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(field_codigo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(botao_proximo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        panel_fotografia.setBackground(new java.awt.Color(255, 51, 102));

        javax.swing.GroupLayout panel_fotografiaLayout = new javax.swing.GroupLayout(panel_fotografia);
        panel_fotografia.setLayout(panel_fotografiaLayout);
        panel_fotografiaLayout.setHorizontalGroup(
            panel_fotografiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_fotografiaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                .addContainerGap())
        );
        panel_fotografiaLayout.setVerticalGroup(
            panel_fotografiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_fotografiaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(label_foto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(panel_acrescenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(field_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(botao_foto)
                        .addGap(27, 27, 27)
                        .addComponent(panel_fotografia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(field_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botao_foto)
                            .addComponent(label_foto))
                        .addGap(53, 53, 53)
                        .addComponent(panel_acrescenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(panel_fotografia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(72, 72, 72))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(panel);
        panel.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(30, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        label_fotografia.setIcon(new ImageIcon("/SISPET/Sispet/src/Imagens/Sem_foto.png"));
        this.atualizaComboEspecie();
        this.atualizaComboPorte();
        return panel;
    }

    private void botao_proximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_proximoActionPerformed
        try {
            ArrayList<String> result;
            codAnterior = field_codigo.getText();
            if(codAnterior.equalsIgnoreCase("")){
                if(!field_nome.getText().equalsIgnoreCase("")){
                    result = control.primeiroAnimal();
                    this.setAtributos(result);
                } else
                    JOptionPane.showMessageDialog(null, "Primeiro selecione um cliente");
            }
            else {
                result = control.proximoAnimal(field_codigo.getText());
                this.setAtributos(result);
            }
        }
        catch (Exception erro) {
            System.out.println("Erro: " + erro.getMessage());
            JOptionPane.showMessageDialog(null,"Não exitem mais cadastros posteriores.");
        }
        finally{
            codAnterior = null;
        }
}//GEN-LAST:event_botao_proximoActionPerformed

    private void botao_anteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_anteriorActionPerformed

        try {
            ArrayList<String> result;
            codAnterior = field_codigo.getText();
            if(codAnterior.equalsIgnoreCase("")){
                if(!field_nome.getText().equalsIgnoreCase("")){
                    result = control.primeiroAnimal();
                    this.setAtributos(result);
                } else
                    JOptionPane.showMessageDialog(null, "Primeiro selecione um cliente");
            }
            else {
                result = control.anteriorAnimal(field_codigo.getText());
                this.setAtributos(result);
            }
        }
        catch (Exception erro) {
            System.out.println("Erro: " + erro.getMessage());
            JOptionPane.showMessageDialog(null,"Não exitem mais cadastros posteriores.");
        }
        finally{
            codAnterior = null;
        }
}//GEN-LAST:event_botao_anteriorActionPerformed

    private void botao_novoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_novoActionPerformed
        codAnterior = field_codigo.getText();
        if(!codAnterior.equalsIgnoreCase(""))
            this.limpaFields();
}//GEN-LAST:event_botao_novoActionPerformed

    private void combo_especieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_especieActionPerformed
        try {
            combo_raca.removeAllItems();
            combo_raca.addItem("");
            ArrayList<String> result = control.consultaRacas((String)combo_especie.getSelectedItem());
            int index = 0;
            while(index < result.size()) {
                combo_raca.addItem(result.get(index));
                index++;
            }
        } catch (Exception ex) {
            System.out.println("Erro ao atualizar o combo de raca dentro da limAnimal \nErro:" + ex.getMessage());
        }
    }//GEN-LAST:event_combo_especieActionPerformed

    private void botao_acrescentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_acrescentaActionPerformed
        if(!codAnterior.equalsIgnoreCase("")){
            if(field_nome.getText().equalsIgnoreCase(""))
                JOptionPane.showMessageDialog(null,"Obrigatório o preenchimento do campo: Nome do Animal");
            else {
                try {
                    ArrayList<String> result = this.capturaDados();
                    control.acrescentaAnimal(result);
                    JOptionPane.showMessageDialog(null,"Gravação realizada com sucesso!");
                } catch (SQLException erro) {
                    System.out.println("Erro: " + erro.getMessage());
                    JOptionPane.showMessageDialog(null, "Problemas no banco de dados! \nNão foi possível efetuar a gravação do cadastro!");
                } catch (Exception erro) {
                    System.out.println("Erro: " + erro.getMessage());
                    JOptionPane.showMessageDialog(null, "Problemas para gravar o cadastro!");
                }
            }            
        }
        else{
            if(field_nome.getText().equalsIgnoreCase(""))  
                JOptionPane.showMessageDialog(null,"Obrigatório o preenchimento do campo: Nome do Animal");
            else
               JOptionPane.showMessageDialog(null, "Cadastro do animal "+field_nome.getText()+" já foi realizado.");
        }
        codAnterior = null;
    }//GEN-LAST:event_botao_acrescentaActionPerformed

    private void botao_fotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_fotoActionPerformed
       JFileChooser fc = new JFileChooser("D:/Imagens");
       fc.setDialogTitle("Carregar imagem de animal");
       fc.setFileFilter(new FileNameExtensionFilter("JPG, GIF, PNG e BMP",
                "jpg", "gif", "png","bmp"));
       int res = fc.showOpenDialog(null);
       if(res == JFileChooser.APPROVE_OPTION) {
            File arquivo = fc.getSelectedFile();
            String Imc = arquivo.getPath();
            ImageIcon imagem = new ImageIcon(Imc);
            Image img = imagem.getImage().getScaledInstance(102, 172,Image.SCALE_DEFAULT);
            imgRedimensionada = new ImageIcon(img);
            label_fotografia.setIcon(imgRedimensionada);
            field_foto.setText(Imc);
        }
    }//GEN-LAST:event_botao_fotoActionPerformed

    public String getCodAnimal() {
        return field_codigo.getText();
    }

    public ArrayList<String> capturaDados(){
        ArrayList<String> result = new ArrayList();
        result.add(field_nome.getText());
        result.add(field_apelido.getText());
        result.add((String)combo_especie.getSelectedItem());
        result.add((String)combo_raca.getSelectedItem());
        result.add((String)combo_porte.getSelectedItem());
        result.add(textArea_observacoes.getText());
        result.add(field_foto.getText());
        //DATA
        if((combo_data_ano.getSelectedIndex() != 0) && (combo_data_mes.getSelectedIndex() != 0) && (combo_data_dia.getSelectedIndex() != 0)){
            result.add((String) combo_data_ano.getSelectedItem());
            result.add(String.valueOf(combo_data_mes.getSelectedIndex()));
            result.add((String) combo_data_dia.getSelectedItem());
        }
        else {
            result.add("");
            result.add("");
            result.add("");
        }
        return result;
    }

    public void setAtributos(ArrayList<String> result) {
        field_codigo.setText(result.get(0));
        field_nome.setText(result.get(1));
        field_apelido.setText(result.get(2));
        combo_especie.setSelectedItem(result.get(3));
        combo_raca.setSelectedItem(result.get(4));
        combo_porte.setSelectedItem(result.get(5));
        textArea_observacoes.setText(result.get(6));
        field_foto.setText(result.get(7));
        //FOTO
        if(!field_foto.getText().equalsIgnoreCase("")) {
            ImageIcon imagem = new ImageIcon(field_foto.getText());
            Image img = imagem.getImage().getScaledInstance(102, 172,Image.SCALE_DEFAULT);
            imgRedimensionada = new ImageIcon(img);
            label_fotografia.setIcon(imgRedimensionada);
        }
        else 
            label_fotografia.setIcon(new ImageIcon("/SISPET/Sispet/src/Imagens/Sem_foto.png"));
        
        //DATA
        if(result.get(8).equalsIgnoreCase("")){
            combo_data_ano.setSelectedIndex(0);//Setar posição inicial
            combo_data_mes.setSelectedIndex(0);
            combo_data_dia.setSelectedIndex(0);
        }
        else {
            combo_data_ano.setSelectedItem(result.get(8));
            combo_data_mes.setSelectedIndex(Integer.parseInt(result.get(9)));
            combo_data_dia.setSelectedIndex(Integer.parseInt(result.get(10)));
        }        
    }

    public void limpaFields(){
        field_codigo.setText("");
        field_nome.setText("");
        field_apelido.setText("");
        combo_especie.setSelectedIndex(0);
        combo_raca.setSelectedIndex(0);
        combo_porte.setSelectedIndex(0);        
        textArea_observacoes.setText("");
        field_foto.setText("");
        label_fotografia.setIcon(new ImageIcon("/SISPET/Sispet/src/Imagens/Sem_foto.png"));
        combo_data_dia.setSelectedIndex(0);
        combo_data_mes.setSelectedIndex(0);
        combo_data_ano.setSelectedIndex(0);
    }

    private void atualizaComboEspecie() {
        combo_especie.removeAllItems();
        combo_especie.addItem("");
        ArrayList<String> result = control.consultaEspecies();
        int index = 0;
        while(index < result.size()) {
            combo_especie.addItem(result.get(index));
            index++;
        }        
    }

    private void atualizaComboPorte() {
        combo_porte.removeAllItems();
        combo_porte.addItem("");
        ArrayList<String> result = control.consultaPortes();
        int index = 0;
        while(index < result.size()) {
            combo_porte.addItem(result.get(index));
            index++;
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botao_acrescenta;
    private javax.swing.JButton botao_anterior;
    private javax.swing.JButton botao_foto;
    private javax.swing.JButton botao_novo;
    private javax.swing.JButton botao_proximo;
    private javax.swing.JComboBox combo_data_ano;
    private javax.swing.JComboBox combo_data_dia;
    private javax.swing.JComboBox combo_data_mes;
    private javax.swing.JComboBox combo_especie;
    private javax.swing.JComboBox combo_porte;
    private javax.swing.JComboBox combo_raca;
    private javax.swing.JTextField field_apelido;
    private java.awt.TextField field_codigo;
    private javax.swing.JTextField field_foto;
    private javax.swing.JTextField field_nome;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel label_acrescenta;
    private javax.swing.JLabel label_apelido;
    private javax.swing.JLabel label_dt_nascimento;
    private javax.swing.JLabel label_especie;
    private javax.swing.JLabel label_foto;
    private javax.swing.JLabel label_fotografia;
    private javax.swing.JLabel label_nome;
    private javax.swing.JLabel label_observacao;
    private javax.swing.JLabel label_porte;
    private javax.swing.JLabel label_raca;
    private javax.swing.JPanel panel_acrescenta;
    private javax.swing.JPanel panel_fotografia;
    private javax.swing.JTextArea textArea_observacoes;
    // End of variables declaration//GEN-END:variables
}
